package com.yuetong.quotation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yuetong.common.annotation.Log;
import com.yuetong.common.core.controller.BaseController;
import com.yuetong.common.core.domain.AjaxResult;
import com.yuetong.common.enums.BusinessType;
import com.yuetong.quotation.domain.YtQuotationDemo;
import com.yuetong.quotation.service.IYtQuotationDemoService;
import com.yuetong.common.utils.poi.ExcelUtil;
import com.yuetong.common.core.page.TableDataInfo;

/**
 * 报价项模板Controller
 * 
 * @author  卓晓君
 * @date 2025-02-11
 */
@RestController
@RequestMapping("/quotation/demo")
public class YtQuotationDemoController extends BaseController
{
    @Autowired
    private IYtQuotationDemoService ytQuotationDemoService;

    /**
     * 查询报价项模板列表
     */
    @PreAuthorize("@ss.hasPermi('quotation:demo:list')")
    @GetMapping("/list")
    public TableDataInfo list(YtQuotationDemo ytQuotationDemo)
    {
        startPage();
        List<YtQuotationDemo> list = ytQuotationDemoService.selectYtQuotationDemoList(ytQuotationDemo);
        return getDataTable(list);
    }

    /**
     * 导出报价项模板列表
     */
    @PreAuthorize("@ss.hasPermi('quotation:demo:export')")
    @Log(title = "报价项模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YtQuotationDemo ytQuotationDemo)
    {
        List<YtQuotationDemo> list = ytQuotationDemoService.selectYtQuotationDemoList(ytQuotationDemo);
        ExcelUtil<YtQuotationDemo> util = new ExcelUtil<YtQuotationDemo>(YtQuotationDemo.class);
        util.exportExcel(response, list, "报价项模板数据");
    }

    /**
     * 获取报价项模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('quotation:demo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ytQuotationDemoService.selectYtQuotationDemoById(id));
    }

    /**
     * 新增报价项模板
     */
    @PreAuthorize("@ss.hasPermi('quotation:demo:add')")
    @Log(title = "报价项模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YtQuotationDemo ytQuotationDemo)
    {
        return toAjax(ytQuotationDemoService.insertYtQuotationDemo(ytQuotationDemo));
    }

    /**
     * 修改报价项模板
     */
    @PreAuthorize("@ss.hasPermi('quotation:demo:edit')")
    @Log(title = "报价项模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YtQuotationDemo ytQuotationDemo)
    {
        return toAjax(ytQuotationDemoService.updateYtQuotationDemo(ytQuotationDemo));
    }

    /**
     * 删除报价项模板
     */
    @PreAuthorize("@ss.hasPermi('quotation:demo:remove')")
    @Log(title = "报价项模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ytQuotationDemoService.deleteYtQuotationDemoByIds(ids));
    }
}
